home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_ImageMagick.idb / usr / freeware / include / magick / image.h.z / image.h
Encoding:
C/C++ Source or Header  |  1999-01-26  |  14.1 KB  |  783 lines

  1. /*
  2.   Image define declarations.
  3. */
  4. #define ColorMatch(color,target,delta) \
  5.   ((((int) ((color).red)-delta) <= (int) ((target).red)) && \
  6.     ((int) ((target).red) <= ((int) ((color).red)+delta)) && \
  7.    (((int) ((color).green)-delta) <= (int) ((target).green)) && \
  8.     ((int) ((target).green) <= ((int) ((color).green)+delta)) && \
  9.    (((int) ((color).blue)-delta) <= (int) ((target).blue)) && \
  10.     ((int) ((target).blue) <= ((int) ((color).blue)+delta)))
  11. #define DegreesToRadians(x) ((x)*M_PI/180.0)
  12. #define Intensity(color)  \
  13.   ((unsigned int) ((color).red*77+(color).green*150+(color).blue*29) >> 8)
  14. #define IsFaxImage(color)  \
  15.   (IsMonochromeImage(image) && ((image)->columns <= 2560))
  16. #define IsGray(color)  \
  17.   (((color).red == (color).green) && ((color).green == (color).blue))
  18. #define MatteMatch(color,target,delta) \
  19.   (ColorMatch(color,target,delta) && ((color).index == (target).index))
  20. #define MaxColormapSize  65535L
  21. #define MaxStacksize  (1 << 15)
  22. #define MaxTextExtent  1664
  23. #define PixelOffset(x,y) image->pixels+((y)*image->columns+(x))
  24. #define Push(up,left,right,delta) \
  25.   if ((p < (segment_stack+MaxStacksize)) && (((up)+(delta)) >= 0) && \
  26.       (((up)+(delta)) < image->rows)) \
  27.     { \
  28.       p->y1=(up); \
  29.       p->x1=(left); \
  30.       p->x2=(right); \
  31.       p->y2=(delta); \
  32.       p++; \
  33.     }
  34. #define RadiansToDegrees(x) ((x)*180/M_PI)
  35. #define ReadQuantum(quantum,p)  \
  36. {  \
  37.   if (image->depth == 8) \
  38.     quantum=UpScale(*p++); \
  39.   else \
  40.     { \
  41.       value=(*p++) << 8;  \
  42.       value|=(*p++);  \
  43.       quantum=value >> (image->depth-QuantumDepth); \
  44.     } \
  45. }
  46. #define ReadQuantumFile(quantum)  \
  47. {  \
  48.   if (image->depth == 8) \
  49.     quantum=UpScale(fgetc(image->file)); \
  50.   else \
  51.     quantum=MSBFirstReadShort(image->file) >> (image->depth-QuantumDepth); \
  52. }
  53. #define SharpenFactor  60.0
  54. #define Transparent  0
  55. #define UncompressImage  UncondenseImage
  56. #define WriteQuantum(quantum,q)  \
  57. {  \
  58.   if (image->depth == 8) \
  59.     *q++=DownScale(quantum); \
  60.   else \
  61.     { \
  62.       value=(quantum); \
  63.       if ((QuantumDepth-image->depth) > 0) \
  64.         value*=257; \
  65.       *q++=value >> 8; \
  66.       *q++=value; \
  67.     } \
  68. }
  69. #define WriteQuantumFile(quantum)  \
  70. {  \
  71.   if (image->depth == 8) \
  72.     (void) fputc(DownScale(quantum),image->file); \
  73.   else \
  74.     if ((QuantumDepth-image->depth) > 0) \
  75.       MSBFirstWriteShort((quantum)*257,image->file); \
  76.     else \
  77.       MSBFirstWriteShort(quantum,image->file); \
  78. }
  79.  
  80. #if defined(QuantumLeap)
  81. /*
  82.   Color quantum is [0..65535].
  83. */
  84. #define DownScale(quantum)  (((unsigned int) (quantum)) >> 8)
  85. #define HexColorFormat "#%04x%04x%04x"
  86. #define MaxRGB  65535L
  87. #define MaxRunlength  65535L
  88. #define Opaque  65535L
  89. #define QuantumDepth  16
  90. #define UpScale(quantum)  (((unsigned int) (quantum))*257)
  91. #define XDownScale(color)  ((unsigned int) (color))
  92. #define XUpScale(color)  ((unsigned int) (color))
  93.  
  94. typedef unsigned short Quantum;
  95. #else
  96. /*
  97.   Color quantum is [0..255].
  98. */
  99. #define DownScale(quantum)  ((unsigned int) (quantum))
  100. #define HexColorFormat "#%02x%02x%02x"
  101. #define MaxRGB  255
  102. #define MaxRunlength  255
  103. #define Opaque  255
  104. #define QuantumDepth  8
  105. #define UpScale(quantum)  ((unsigned int) (quantum))
  106. #define XDownScale(color)  (((unsigned int) (color)) >> 8)
  107. #define XUpScale(color)  (((unsigned int) (color))*257)
  108.  
  109. typedef unsigned char Quantum;
  110. #endif
  111.  
  112. /*
  113.   Enumeration declarations.
  114. */
  115. typedef enum
  116. {
  117.   UndefinedAlignment,
  118.   LeftAlignment,
  119.   CenterAlignment,
  120.   RightAlignment
  121. } AlignmentType;
  122.  
  123. typedef enum
  124. {
  125.   UndefinedClass,
  126.   DirectClass,
  127.   PseudoClass
  128. } ClassType;
  129.  
  130. typedef enum
  131. {
  132.   UndefinedColorspace,
  133.   RGBColorspace,
  134.   GRAYColorspace,
  135.   TransparentColorspace,
  136.   OHTAColorspace,
  137.   XYZColorspace,
  138.   YCbCrColorspace,
  139.   YCCColorspace,
  140.   YIQColorspace,
  141.   YPbPrColorspace,
  142.   YUVColorspace,
  143.   CMYKColorspace,
  144.   sRGBColorspace
  145. } ColorspaceType;
  146.  
  147. typedef enum
  148. {
  149.   UndefinedCompositeOp = 0,
  150.   OverCompositeOp,
  151.   InCompositeOp,
  152.   OutCompositeOp,
  153.   AtopCompositeOp,
  154.   XorCompositeOp,
  155.   PlusCompositeOp,
  156.   MinusCompositeOp,
  157.   AddCompositeOp,
  158.   SubtractCompositeOp,
  159.   DifferenceCompositeOp,
  160.   BumpmapCompositeOp,
  161.   ReplaceCompositeOp,
  162.   ReplaceRedCompositeOp,
  163.   ReplaceGreenCompositeOp,
  164.   ReplaceBlueCompositeOp,
  165.   ReplaceMatteCompositeOp,
  166.   BlendCompositeOp,
  167.   DisplaceCompositeOp
  168. } CompositeOperator;
  169.  
  170. typedef enum
  171. {
  172.   UndefinedCompression,
  173.   NoCompression,
  174.   JPEGCompression,
  175.   LZWCompression,
  176.   RunlengthEncodedCompression,
  177.   ZipCompression
  178. } CompressionType;
  179.  
  180. typedef enum
  181. {
  182.   UndefinedFilter,
  183.   PointFilter,
  184.   BoxFilter,
  185.   TriangleFilter,
  186.   HermiteFilter,
  187.   HanningFilter,
  188.   HammingFilter,
  189.   BlackmanFilter,
  190.   GaussianFilter,
  191.   QuadraticFilter,
  192.   CubicFilter,
  193.   CatromFilter,
  194.   MitchellFilter,
  195.   LanczosFilter,
  196.   BesselFilter,
  197.   SincFilter
  198. } FilterType;
  199.  
  200. typedef enum
  201. {
  202.   UndefinedId,
  203.   ImageMagickId
  204. } IdType;
  205.  
  206. typedef enum
  207. {
  208.   UndefinedInterlace,
  209.   NoInterlace,
  210.   LineInterlace,
  211.   PlaneInterlace,
  212.   PartitionInterlace
  213. } InterlaceType;
  214.  
  215. typedef enum
  216. {
  217.   UndefinedLayer,
  218.   RedLayer,
  219.   GreenLayer,
  220.   BlueLayer,
  221.   MatteLayer
  222. } LayerType;
  223.  
  224. typedef enum
  225. {
  226.   UniformNoise,
  227.   GaussianNoise,
  228.   MultiplicativeGaussianNoise,
  229.   ImpulseNoise,
  230.   LaplacianNoise,
  231.   PoissonNoise
  232. } NoiseType;
  233.  
  234. typedef enum
  235. {
  236.   PointMethod = 0,
  237.   ReplaceMethod,
  238.   FloodfillMethod,
  239.   ResetMethod
  240. } PaintMethod;
  241.  
  242. typedef enum
  243. {
  244.   RotatePreview = 0,
  245.   ShearPreview,
  246.   RollPreview,
  247.   HuePreview,
  248.   SaturationPreview,
  249.   BrightnessPreview,
  250.   GammaPreview,
  251.   SpiffPreview,
  252.   DullPreview,
  253.   GrayscalePreview,
  254.   QuantizePreview,
  255.   DespecklePreview,
  256.   ReduceNoisePreview,
  257.   AddNoisePreview,
  258.   SharpenPreview,
  259.   BlurPreview,
  260.   ThresholdPreview,
  261.   EdgeDetectPreview,
  262.   SpreadPreview,
  263.   SolarizePreview,
  264.   ShadePreview,
  265.   RaisePreview,
  266.   SegmentPreview,
  267.   SwirlPreview,
  268.   ImplodePreview,
  269.   WavePreview,
  270.   OilPaintPreview,
  271.   CharcoalDrawingPreview
  272. } PreviewType;
  273.  
  274. typedef enum
  275. {
  276.   UndefinedPrimitive = 0,
  277.   PointPrimitive,
  278.   LinePrimitive,
  279.   RectanglePrimitive,
  280.   FillRectanglePrimitive,
  281.   EllipsePrimitive,
  282.   FillEllipsePrimitive,
  283.   PolygonPrimitive,
  284.   FillPolygonPrimitive,
  285.   ColorPrimitive,
  286.   MattePrimitive,
  287.   TextPrimitive,
  288.   ImagePrimitive
  289. } PrimitiveType;
  290.  
  291. typedef enum
  292. {
  293.   UndefinedIntent,
  294.   SaturationIntent,
  295.   PerceptualIntent,
  296.   AbsoluteIntent,
  297.   RelativeIntent
  298. } RenderingIntent;
  299.  
  300. typedef enum
  301. {
  302.   UndefinedResolution,
  303.   PixelsPerInchResolution,
  304.   PixelsPerCentimeterResolution
  305. } ResolutionType;
  306.  
  307. /*
  308.   Typedef declarations.
  309. */
  310. typedef struct _ColorPacket
  311. {
  312.   Quantum
  313.     red,
  314.     green,
  315.     blue;
  316.  
  317.   unsigned char
  318.     flags;
  319.  
  320.   char
  321.     key[3];
  322.  
  323.   unsigned short
  324.     index;
  325. } ColorPacket;
  326.  
  327. typedef struct _ContributionInfo
  328. {
  329.   int
  330.     pixel;
  331.  
  332.   double
  333.     weight;
  334. } ContributionInfo;
  335.  
  336. typedef struct _FilterInfo
  337. {
  338.   double
  339.     (*function)(double),
  340.     width;
  341. } FilterInfo;
  342.  
  343. typedef struct _FrameInfo
  344. {
  345.   int
  346.     x,
  347.     y;
  348.  
  349.   unsigned int
  350.     width,
  351.     height;
  352.  
  353.   int
  354.     inner_bevel,
  355.     outer_bevel;
  356. } FrameInfo;
  357.  
  358. typedef struct _ImageInfo
  359. {
  360.   char
  361.     *filename,
  362.     magick[MaxTextExtent];
  363.  
  364.   unsigned int
  365.     affirm,
  366.     subimage,
  367.     subrange;
  368.  
  369.   char
  370.     *server_name,
  371.     *font,
  372.     *pen,
  373.     *box,
  374.     *size,
  375.     *tile,
  376.     *density,
  377.     *page,
  378.     *dispose,
  379.     *delay,
  380.     *iterations,
  381.     *texture,
  382.     *view;
  383.  
  384.   unsigned int
  385.     adjoin;
  386.  
  387.   ColorspaceType
  388.     colorspace;
  389.  
  390.   CompressionType
  391.     compression;
  392.  
  393.   unsigned int
  394.     dither;
  395.  
  396.   InterlaceType
  397.     interlace;
  398.  
  399.   unsigned int
  400.     monochrome,
  401.     pointsize,
  402.     quality,
  403.     verbose;
  404.  
  405.   FilterType
  406.     filter;
  407.  
  408.   PreviewType
  409.     preview_type;
  410.  
  411.   char
  412.     *undercolor;
  413.  
  414.   unsigned int
  415.     ping;
  416. } ImageInfo;
  417.  
  418. typedef struct _PointInfo
  419. {
  420.   float
  421.     x,
  422.     y;
  423. } PointInfo;
  424.  
  425. typedef struct _PrimitiveInfo
  426. {
  427.   PrimitiveType
  428.     primitive;
  429.  
  430.   unsigned int
  431.     coordinates;
  432.  
  433.   int
  434.     x,
  435.     y;
  436.  
  437.   PaintMethod
  438.     method;
  439.  
  440.   char
  441.     *text;
  442. } PrimitiveInfo;
  443.  
  444. typedef struct _QuantizeInfo
  445. {
  446.   unsigned int
  447.     number_colors,
  448.     tree_depth,
  449.     dither;
  450.  
  451.   ColorspaceType
  452.     colorspace;
  453. } QuantizeInfo;
  454.  
  455. typedef struct _RectangleInfo
  456. {
  457.   unsigned int
  458.     width,
  459.     height;
  460.  
  461.   int
  462.     x,
  463.     y;
  464. } RectangleInfo;
  465.  
  466. typedef struct _RunlengthPacket
  467. {
  468.   Quantum
  469.     red,
  470.     green,
  471.     blue,
  472.     length;
  473.  
  474.   unsigned short
  475.     index;
  476. } RunlengthPacket;
  477.  
  478. typedef struct _SegmentInfo
  479. {
  480.   int
  481.     x1,
  482.     y1,
  483.     x2,
  484.     y2;
  485. } SegmentInfo;
  486.  
  487. typedef struct _AnnotateInfo
  488. {
  489.   ImageInfo
  490.     *image_info;
  491.  
  492.   char
  493.     *geometry,
  494.     *text,
  495.     *primitive;
  496.  
  497.   unsigned int
  498.     linewidth;
  499.  
  500.   AlignmentType
  501.     alignment;
  502.  
  503.   unsigned int
  504.     height;
  505. } AnnotateInfo;
  506.  
  507. typedef struct _ChromaticityInfo
  508. {
  509.   PointInfo
  510.     red_primary,
  511.     green_primary,
  512.     blue_primary,
  513.     white_point;
  514. } ChromaticityInfo;
  515.  
  516. typedef struct _ColorProfileInfo
  517. {
  518.   unsigned int
  519.     length;
  520.  
  521.   unsigned char
  522.     *info;
  523. } ColorProfileInfo;
  524.  
  525. typedef struct _Image
  526. {
  527.   FILE
  528.     *file;
  529.  
  530.   int
  531.     status,
  532.     temporary;
  533.  
  534.   char
  535.     filename[MaxTextExtent];
  536.  
  537.   long int
  538.     filesize;
  539.  
  540.   int
  541.     pipe;
  542.  
  543.   char
  544.     magick[MaxTextExtent],
  545.     *comments,
  546.     *label,
  547.     *text;
  548.  
  549.   IdType
  550.     id;
  551.  
  552.   ClassType
  553. #if defined(__cplusplus) || defined(c_plusplus)
  554.     c_class;
  555. #else
  556.     class;
  557. #endif
  558.  
  559.   unsigned int
  560.     matte;
  561.  
  562.   CompressionType
  563.     compression;
  564.  
  565.   unsigned int
  566.     columns,
  567.     rows,
  568.     depth;
  569.  
  570.   InterlaceType
  571.     interlace;
  572.  
  573.   unsigned int
  574.     scene,
  575.     number_scenes;
  576.  
  577.   char
  578.     *montage,
  579.     *directory;
  580.  
  581.   ColorPacket
  582.     *colormap;
  583.  
  584.   unsigned int
  585.     colors;
  586.  
  587.   RenderingIntent
  588.     rendering_intent;
  589.  
  590.   double
  591.     gamma;
  592.  
  593.   ChromaticityInfo
  594.     chromaticity;
  595.  
  596.   ColorProfileInfo
  597.     color_profile;
  598.  
  599.   ResolutionType
  600.     units;
  601.  
  602.   float
  603.     x_resolution,
  604.     y_resolution;
  605.  
  606.   unsigned int
  607.     mean_error_per_pixel;
  608.  
  609.   double
  610.     normalized_mean_error,
  611.     normalized_maximum_error;
  612.  
  613.   unsigned long
  614.     total_colors;
  615.  
  616.   char
  617.     *signature;
  618.  
  619.   RunlengthPacket
  620.     *pixels,
  621.     *packet;
  622.  
  623.   unsigned long
  624.     packets;
  625.  
  626.   unsigned int
  627.     packet_size;
  628.  
  629.   unsigned char
  630.     *packed_pixels;
  631.  
  632.   ColorPacket
  633.     background_color,
  634.     border_color,
  635.     matte_color;
  636.  
  637.   long int
  638.     magick_time;
  639.  
  640.   char
  641.     magick_filename[MaxTextExtent];
  642.  
  643.   unsigned int
  644.     magick_columns,
  645.     magick_rows;
  646.  
  647.   char
  648.     *geometry,
  649.     *page;
  650.  
  651.   unsigned int
  652.     dispose,
  653.     delay,
  654.     iterations;
  655.  
  656.   FilterType
  657.     filter;
  658.  
  659.   unsigned int
  660.     orphan;
  661.  
  662.   struct _Image
  663.     *previous,
  664.     *list,
  665.     *next;
  666. } Image;
  667.  
  668. /*
  669.   Image utilities routines.
  670. */
  671. extern Export void
  672.   CommentImage(Image *,char *),
  673.   LabelImage(Image *,char *);
  674.  
  675. extern Export Image
  676.   *AddNoiseImage(Image *,NoiseType),
  677.   *AllocateImage(const ImageInfo *),
  678.   *AppendImages(Image *),
  679.   *AverageImages(Image *),
  680.   *BorderImage(Image *,RectangleInfo *),
  681.   *BlurImage(Image *,double),
  682.   *ChopImage(Image *,RectangleInfo *),
  683.   *CloneImage(Image *,const unsigned int,const unsigned int,const unsigned int),
  684.   *CropImage(Image *,RectangleInfo *),
  685.   *DespeckleImage(Image *),
  686.   *EdgeImage(Image *,double),
  687.   *EmbossImage(Image *),
  688.   *EnhanceImage(Image *),
  689.   *FlipImage(Image *),
  690.   *FlopImage(Image *),
  691.   *FrameImage(Image *,FrameInfo *),
  692.   *ImplodeImage(Image *,double),
  693.   **ListToGroupImage(Image *,unsigned int *),
  694.   *MagnifyImage(Image *),
  695.   *MinifyImage(Image *),
  696.   *OilPaintImage(Image *,const unsigned int),
  697.   *ReadImage(ImageInfo *),
  698.   *ReadPICTImage(ImageInfo *),
  699.   *ReduceNoiseImage(Image *),
  700.   *RollImage(Image *,int,int),
  701.   *RotateImage(Image *,double,const unsigned int,const unsigned int),
  702.   *SampleImage(Image *,unsigned int,unsigned int),
  703.   *ScaleImage(Image *,const unsigned int,const unsigned int),
  704.   *ShadeImage(Image *,unsigned int,double,double),
  705.   *SharpenImage(Image *,double),
  706.   *ShearImage(Image *,double,double,const unsigned int),
  707.   *SpreadImage(Image *,unsigned int),
  708.   *StereoImage(Image *,Image *),
  709.   *SwirlImage(Image *,double),
  710.   *WaveImage(Image *,double,double),
  711.   *ZoomImage(Image *,const unsigned int,const unsigned int);
  712.  
  713. extern Export int
  714.   ParseImageGeometry(char *,int *,int *,unsigned int *,unsigned int *);
  715.  
  716. extern Export unsigned int
  717.   IsGeometry(char *),
  718.   IsGrayImage(Image *),
  719.   IsMonochromeImage(Image *),
  720.   IsPseudoClass(Image *),
  721.   IsSubimage(char *,unsigned int),
  722.   PingImage(ImageInfo *,unsigned int *,unsigned int *),
  723.   PlasmaImage(Image *,SegmentInfo *,int,int),
  724.   UncondenseImage(Image *),
  725.   WriteNTImage(const ImageInfo *,Image *),
  726.   WriteImage(ImageInfo *,Image *);
  727.  
  728. extern Export void
  729.   AllocateNextImage(const ImageInfo *,Image *),
  730.   AnnotateImage(Image *,AnnotateInfo *),
  731.   BlackImage(Image *),
  732.   CloseImage(Image *),
  733.   ColorFloodfillImage(Image *,int,int,const ColorPacket *,const int),
  734.   ColorizeImage(Image *,char *,char *),
  735.   CompositeImage(Image *,const CompositeOperator,Image *,const int,const int),
  736.   CompressColormap(Image *),
  737.   CondenseImage(Image *),
  738.   ContrastImage(Image *,const unsigned int),
  739.   CycleColormapImage(Image *,int),
  740.   DescribeImage(Image *,FILE *,const unsigned int),
  741.   DestroyImage(Image *),
  742.   DestroyImageInfo(ImageInfo *),
  743.   DestroyImages(Image *),
  744.   DrawImage(Image *,AnnotateInfo *),
  745.   EqualizeImage(Image *),
  746.   GammaImage(Image *,char *),
  747.   GetAnnotateInfo(AnnotateInfo *),
  748.   GetImageInfo(ImageInfo *),
  749.   GetQuantizeInfo(QuantizeInfo *),
  750.   HSLTransform(double,const double,const double,Quantum *,Quantum *,Quantum *),
  751.   LayerImage(Image *,LayerType),
  752.   MapImage(Image *,Image *,const unsigned int),
  753.   MapImages(Image *,Image *,const unsigned int),
  754.   MatteFloodfillImage(Image *,int,int,const unsigned int,const int),
  755.   ModulateImage(Image *,char *),
  756.   MogrifyImage(ImageInfo *,int,char **,Image **),
  757.   MogrifyImages(ImageInfo *,int,char **,Image **),
  758.   NegateImage(Image *,unsigned int),
  759.   NormalizeImage(Image *),
  760.   NumberColors(Image *,FILE *),
  761.   OpaqueImage(Image *,char *,char *),
  762.   OpenImage(const ImageInfo *,Image *,const char *),
  763.   QuantizationError(Image *),
  764.   QuantizeImage(QuantizeInfo *,Image *),
  765.   QuantizeImages(QuantizeInfo *,Image *),
  766.   RaiseImage(Image *,RectangleInfo *,const int),
  767.   RGBTransformImage(Image *,const unsigned int),
  768.   SegmentImage(Image *,const unsigned int,const unsigned int,const double,
  769.     const double),
  770.   SetImageInfo(ImageInfo *,unsigned int),
  771.   SetNumberScenes(Image *),
  772.   SignatureImage(Image *),
  773.   SolarizeImage(Image *,const double),
  774.   SortColormapByIntensity(Image *),
  775.   SyncImage(Image *),
  776.   TextureImage(Image *,char *),
  777.   ThresholdImage(Image *,double),
  778.   TransformHSL(const Quantum,const Quantum,const Quantum,double *,double *,
  779.     double *),
  780.   TransformImage(Image **,char *,char *),
  781.   TransformRGBImage(Image *,const unsigned int),
  782.   TransparentImage(Image *,char *);
  783.